package com.wits.qso.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import net.sf.json.JSONObject;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;

import com.wits.platform.entity.BaseEntity;

@Entity
@Table(name="qso_aid")
public class Aid extends BaseEntity {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	/**课件代码*/
	private String id;
	/**教师ID*/
	private Teacher teaid;
	/**课件名称*/
	private String name;
	/**课件路径*/
	private String path;
	/**课件说明*/
	private String intro;
	/**是否共享*/
	private String share;
	/**课程内容id*/
	private CreContent crecntid = null;
	
	@Id
	@GenericGenerator(name = "idGen", 
					strategy = "com.wits.platform.common.id.generator.IDGenerator",
					parameters={ 
								@Parameter(name = "segment_value", value = "QSO_AID_ID"), 
								@Parameter(name="table_name",value="wits_id_generator"),
								@Parameter(name="value_column_name",value="gen_value"),
								@Parameter(name="segment_column_name",value="gen_name"),
								@Parameter(name="segment_value_length",value="5"),
								@Parameter(name="sq_format",value="%03d"), 
								@Parameter(name="sq_prefix",value="AID") 
					})
	@GeneratedValue(generator = "idGen")
	@Column(name = "aid_id", nullable = false, insertable = true, updatable = false, length = 10)
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}
	
	@ManyToOne
	@JoinColumn(name="aid_teaid")
	public Teacher getTeaid() {
		return teaid;
	}

	public void setTeaid(Teacher teaid) {
		this.teaid = teaid;
	}
	@Column(name="aid_name",length=100)
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	@Column(name="aid_path",length=1000)
	public String getPath() {
		return path;
	}

	public void setPath(String path) {
		this.path = path;
	}
	@Column(name="aid_intro",length=500)
	public String getIntro() {
		return intro;
	}

	public void setIntro(String intro) {
		this.intro = intro;
	}

	@Column(name="aid_share",length=2)
	public String getShare() {
		return share;
	}

	public void setShare(String share) {
		this.share = share;
	}
	
	@ManyToOne
	@JoinColumn(name="aid_crecntid")
	public CreContent getCrecntid() {
		return crecntid;
	}

	public void setCrecntid(CreContent crecntid) {
		this.crecntid = crecntid;
	}

	@Override
	public String display() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String toString(){
		return "{\"id\":\"" + this.id 
				+ "\",\"teaTitle\":\"" + this.teaid.getTerName()
				+ "\",\"name\":\"" + this.name 
				+ "\",\"share\":\"" + this.share
				+ "\",\"intro\":\"" + this.intro
				+ "\",\"remark\":\"" + this.remark
				+ "\" }";
	}
}
